package com.guoxin.concurrentcy.chapter1;


/**
 * 模板方法
 *
 * @author guoxin
 * @date 2019/7/1
 */
public abstract class AbstractTemplateMethod {

    public final void print(String message) {
        System.out.println("******************");
        wrapPrint(message);
        System.out.println("******************");
    }

    protected abstract void wrapPrint(String message);

    public static void main(String[] args) {
        AbstractTemplateMethod t1 = new AbstractTemplateMethod() {
            @Override
            protected void wrapPrint(String message) {
                System.out.println("*" + message + "*");
            }
        };
        t1.print("Hello Thread");

        AbstractTemplateMethod t2 = new AbstractTemplateMethod() {
            @Override
            protected void wrapPrint(String message) {
                System.out.println("-" + message + "-");
            }
        };
        t2.print("Hello Thread");
    }
}
